﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using CPAScoringPerformanceTester.Models;

namespace CPAScoringPerformanceTester.Windows
{
    /// <summary>
    /// PreferenceWindow.xaml 的交互逻辑
    /// </summary>
    public partial class PreferenceWindow : Window
    {
        public RelayCommand ApplyCommand { get; set; }
        public RelayCommand SetDefaultCommand { get; set; }
        public RelayCommand CloseCommand { get; set; }

        public PreferenceWindow()
        {
            ApplyCommand = new RelayCommand(() => Preference.Global.Apply());
            SetDefaultCommand = new RelayCommand(SetDefault);
            CloseCommand = new RelayCommand(() => this.Close());
            InitializeComponent();
        }

        private void SetDefault()
        {
            if (Preference.Global.SetDefault())
            {
                Preference.Global.Apply();
                this.Close();
            }
            else
            {
                MessageBox.Show("Failed! Please try again...");
            }
        }
    }
}
